{php include wl_template('common/header');}
<ul class="nav nav-tabs">
	<li class="active"><a href="javascript:;">评论详情</a></li>
</ul>
<div class="app-content">
    <div class="app-form">
         <div class="panel panel-default">
            <form  method="post" class="form-horizontal form" novalidate="novalidate" id="dataform">
                {if empty($id)}
                {if !is_store()}
                <div class="form-group">
                    <label class="col-sm-2 control-label">评价商户</label>
                    <div class="col-sm-9">
                        <select name="data[sid]" onchange="changesid(this)" class="form-control select2" required style="width: 100%;">
                            {loop $storeList $item}
                            <option value="{$item['id']}">{$item['storename']}</option>
                            {/loop}
                        </select>
                    </div>
                </div>
                {/if}
                <div class="form-group">
                    <label class="col-sm-2 control-label">评价商品</label>
                    <div class="col-sm-9">
                        <div class='input-group' style="width: 100%;">
                            <div class="input-group" style="width: 100%;">
                                <input type="text" class="form-control col-sm-9 selectGoods_name" id="namemerchant" name="" value="" disabled>
                                <span class="input-group-btn"><button class="btn btn-default" id="selectgood" {if is_store()} sid ="{$_W['storeid']}" {else} sid ="{$storeList[0]['id']}" {/if} data-toggle="selectGoods" type="button" >选择商品</button></span>
                                <input type="hidden" value="" class="selectGoods_id" name="data[gid]" id="idgoods">
                                <input type="hidden" value="" class="selectGoods_plugin" name="data[plugin]" id="pluginname">
                            </div>
                            <div class="input-group " style="margin-top:.5em;">
                                <img src="../web/resource/images/nopic.jpg" class="img-responsive img-thumbnail selectGoods_logo" width="150" id="imgmerchant" />
                                <em class="close" style="position:absolute; top: 0px; right: -14px;" title="删除" onclick="remove_merchant(this)">×</em>
                            </div>
                        </div>
                    </div>
                </div>
                {/if}
                <div class="form-group">
                    <label class="col-sm-2 control-label">评论时间</label>
                    <div class="col-sm-9">
                        {php echo tpl_form_field_date('data[time]', '', true);}
                    </div>
                </div>
                <div class="form-group" id="noleveldiv">
                    <label class="col-sm-2 control-label must">评分等级</label>
                    <div class="col-sm-9">
                        <div class="star-rating rating-xs rating-active">
                            <input type="hidden" name="data[star]" id="star" value="" />
                            <div class="rating-container rating-gly-star">
                                <img src="./resource/images/star-off-big.png" alt="1" title="非常差" class="star">
                                <img src="./resource/images/star-off-big.png" alt="2" title="不太好" class="star">
                                <img src="./resource/images/star-off-big.png" alt="3" title="一般" class="star">
                                <img src="./resource/images/star-off-big.png" alt="4" title="很好" class="star">
                                <img src="./resource/images/star-off-big.png" alt="5" title="非常棒" class="star">
                            </div>
                            <div class="caption"></div>
                            <script type="text/javascript">
                                $('.star').click(function(){
                                    var _t = $(this);
                                    var star = _t.attr('alt');
                                    $('#star').val(star);
                                    $('.caption').html('');
                                    if(star==1){
                                        $('.caption').html('<span class="label label-default">非常差</span>');
                                    }else if(star==2){
                                        $('.caption').html('<span class="label label-warning">不太好</span>');
                                    }else if(star==3){
                                        $('.caption').html('<span class="label label-info">一般</span>');
                                    }else if(star==4){
                                        $('.caption').html('<span class="label label-success">很好!</span>');
                                    }else if(star==5){
                                        $('.caption').html('<span class="label label-danger">非常棒!!</span>');
                                    }
                                    $(".star").each(function(){
                                        $(".rating-container").find('img').each(function(){
                                            var _this = $(this);
                                            if(_this.attr('alt') <= star){
                                                _this.attr('src','./resource/images/star-on-big.png');
                                            }else{
                                                _this.attr('src','./resource/images/star-off-big.png');
                                            }
                                        }
                                        );
                                    });

                                });
                            </script>
                        </div>
                        <span class="help-block text-danger" id="nolevel" style="display:none">请选择评分等级</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">用户头像</label>
                    <div class="col-sm-9">
                         {php echo attachment_select('data[headimg]', $data['headimg'])}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">用户昵称</label>
                    <div class="col-sm-9">
                         <input type="text" class="form-control" name="data[nickname]" value="">
                    </div>
                </div>
                <div class="form-group">
                      <label class="col-sm-2 control-label must">首次评价</label>
                    <div class="col-sm-9">
                        <textarea name="data[text]" class="form-control" data-rule-required="true" aria-required="true"></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label"></label>
                    <div class="col-sm-9">
                        {php echo attachment_select_multi('pic',$data['pictow']);}
                     </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">首次回复</label>
                    <div class="col-sm-9">
                        <textarea name="data[replytextone]" class="form-control"></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label"></label>
                    <div class="col-sm-9">
                        {php echo attachment_select_multi('replypicone', $data['replypicone']);}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label"></label>
                    <div class="col-sm-9">
                        <input type="submit" value="提交" class="btn btn-primary min-width">
                        <input type="hidden" name="token" value="{$_W['token']}">
                        <input type="hidden" name="id" value="{$_GPC['id']}">
                        <input type="hidden" name="page" value='{$pindex}' />
                        <input type="button" name="back" onclick="history.back()" style="margin-left:10px;" value="返回列表" class="btn btn-default min-width">
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
	$('#dataform').submit(function(){
		
		var  star = $('#star').val();
		var  headimg = $('input[name="data[headimg]"]').val();
		var  nickname = $('input[name="data[nickname]"]').val();
		var  text = $('textarea[name="data[text]"]').val();
		var  replytextone = $('textarea[name="data[replytextone]"]').val();
		if(star==''||!$.trim(headimg)||!$.trim(nickname)||!$.trim(text)||!$.trim(replytextone)) {
			util.tips("未完善！");	
			return false;
		}
	});

	function changesid(asd){
	    var sid = $(asd).val();
	    $('#selectgood').attr('sid',sid);
    }

    function remove_merchant(obj){
        $('#namemerchant').val('');
        $('#idgoods').val('');
        $('#pluginname').val('');
        $('#imgmerchant').attr("src",'../web/resource/images/nopic.jpg');
    }

</script>
{php include wl_template('common/footer');}